home *** CD-ROM | disk | FTP | other *** search
/ Internet.Works 41 / Issue 41.iso / pc / PCSoftware / Netscape 6 Official Release / nim.xpi / bin / chrome / aim.jar / content / aim / chatInviteBuddy.js < prev    next >
Encoding:
Text File  |  2000-10-05  |  10.0 KB  |  272 lines

  1. // globals
  2. // window arguments defined here, but may not be used.
  3. // mainly to test & explain valid arguments.
  4.  
  5. /**
  6. var invitedScreenNames = window.arguments[0]
  7. var inviteToExistingWindow=window.arguments[1]
  8. var inviteMode=window.arguments[2]
  9. var inviteProposalObj=window.arguments[3]
  10. **/
  11.  
  12. inviteArgsObj = window.arguments[0];
  13.  
  14. invitedScreenNames = inviteArgsObj.invitedScreenNames;
  15. inviteToExistingWindow = inviteArgsObj.inviteToExistingWindow;
  16. inviteMode = inviteArgsObj.inviteMode;
  17.  
  18. inviteProposalObj=inviteArgsObj.inviteProposalObj;
  19. inviteProposalScreenName = inviteArgsObj.inviteProposalScreenName;
  20. inviteToExistingRoom = inviteArgsObj.inviteToExistingRoom;
  21.  
  22.  
  23. // for incoming chat invitation
  24. var incomingChatScreenName = inviteProposalScreenName;
  25. var incomingChatWarningLevel;
  26. var incomingChatRoomName;
  27. var incomingChatRoomDate;
  28. var incomingChatRoomInviteMsg;
  29. var incomingChatRoom;
  30.  
  31. var ChatManagerCallBack = new Object();
  32. var RoomCreationTimeStamp = null;
  33.  
  34. ChatManagerCallBack.OnRequestRoomComplete =  function(roomName,chatRoomObj){
  35.     dump("before doing GetName\n");
  36.     incomingChatRoom=chatRoomObj;
  37.     incomingChatRoomName = chatRoomObj.GetName();
  38.     dump("OnRequestRoomComplete " + incomingChatRoomName + "\n");
  39.     document.getElementById("chatRendezvousRoomName001").setAttribute("value",incomingChatRoomName);    
  40. //    document.getElementById("chatRendezvousRoomName001").value=incomingChatRoomName;    
  41.     dump("leaving onrequestroomcomplete\n");
  42. }
  43.  
  44.  
  45. ChatManagerCallBack.OnRequestRoomError =  function(roomName,errMsg){
  46.     dump("OnRequestRoomError: there was an error \n");
  47.  
  48. }
  49.  
  50.  
  51. myExecutionCallback = new Object();
  52. myExecutionCallback.ExecuteIfReady = function()
  53. {
  54. // get chatroom and callbacks
  55.   dump ("executeifready\n");
  56.     inviteProposalObj.Accept();
  57.     aimChatManager().RequestProposedRoom(ChatManagerCallBack, inviteProposalObj);
  58. }
  59.  
  60. function chatInviteBuddyOnWinLoad(){
  61.  
  62.     /* VISHY - this is a performance optimization. 
  63.        Since chat needs time to get ready, this tells it to 
  64.        get ready, well before we actually use it */
  65.     aimChatManager().ExecuteIfReady(null);
  66.  
  67.     dump("chatInviteBuddyOnWinLoad\n");
  68.  
  69.     if(inviteMode && inviteMode=="incomingchat"){
  70.         dump("incoming chat\n");
  71.         document.getElementById("cibdeck001").setAttribute("index",2)
  72.  
  73.         //incomingChatScreenName = "testscreename";
  74.         incomingChatWarningLevel =  " " + aimString("chat.WarningLevel").replace(/%Level%/, inviteProposalObj.GetProposer().GetWarningPercent());
  75.         incomingChatRoomName = " ";
  76.         incomingChatRoomDate= new Date();
  77.         incomingChatRoomInviteMsg = inviteProposalObj.GetInvitation();
  78.         dump("Invite Msg is " + incomingChatRoomInviteMsg + "\n");
  79.         document.getElementById("chatRendezvousScreenName001").setAttribute("value",incomingChatScreenName);
  80. //        document.getElementById("chatRendezvousScreenName001").value=incomingChatScreenName;
  81.         document.getElementById("chatRendezvousScreenName002").setAttribute("value",incomingChatScreenName);
  82. //        document.getElementById("chatRendezvousScreenName002").value=incomingChatScreenName;
  83.         document.getElementById("chatRendezvousWarningLevel001").setAttribute("value",incomingChatWarningLevel);
  84. //        document.getElementById("chatRendezvousWarningLevel001").value=incomingChatWarningLevel;
  85.         document.getElementById("chatRendezvousRoomName001").setAttribute("value",incomingChatRoomName);
  86. //        document.getElementById("chatRendezvousRoomName001").value=incomingChatRoomName;
  87.         document.getElementById("chatRendezvousChatRoomDate").setAttribute("value",incomingChatRoomDate);
  88. //        document.getElementById("chatRendezvousChatRoomDate").value=incomingChatRoomDate;
  89.         document.getElementById("chatRendezvousInvitationMsg").setAttribute("value", incomingChatRoomInviteMsg);
  90. //        document.getElementById("chatRendezvousInvitationMsg").value= incomingChatRoomInviteMsg;
  91.         
  92.         //XXXVISHY - unfortunately you need to get the Chat Room 
  93.         // in order to find its name ;-)
  94.         dump("About to call ExecuteIfReady\n");
  95.         aimChatManager().ExecuteIfReady(myExecutionCallback);
  96.         
  97.     }
  98.  
  99.     if(inviteMode && inviteMode=="outgoingchat"){
  100.         dump("outgoing chat\n");
  101.         document.getElementById("cibdeck001").setAttribute("index",1)
  102.         //alert(document.getElementById("cibdeck001"))
  103.         
  104.         dump('ChatInviteBuddy: Loading \n')
  105.         
  106.         if(window.arguments[0]){
  107.             
  108.             dump('ChatInviteBuddy:screenNames: '+invitedScreenNames+'\n');
  109.         }
  110.         else{
  111.             invitedScreenNames = "";
  112.             dump('ChatInviteBuddy:no pre invited screenNames: '+invitedScreenNames+'\n');
  113.         
  114.         }
  115.         
  116. //        document.getElementById("invitedscreennames").setAttribute("value",invitedScreenNames);
  117.         
  118.         document.getElementById("invitedscreennames").value=invitedScreenNames;
  119.         
  120. //        document.getElementById("invitationmsg").setAttribute("value","Join me in this Buddy Chat")
  121. //        document.getElementById("invitationmsg").value="Join me in this Buddy Chat";
  122.         
  123.         dump("cib:setting invite msg: \n");
  124.         //document.getElementById("invitationmsg")["value"]="Join me in this Buddy Chat"
  125.         document.getElementById("invitationmsg").value=aimString("chat.JoinMe");
  126. //        document.getElementById("invitationmsg").setAttribute("value", aimString("chat.JoinMe"));
  127.         
  128.         
  129.         
  130.         if(inviteToExistingWindow){
  131.             dump("inviteToExisting window\n");
  132.             document.getElementById("buddychatroomname").setAttribute("disabled","true");
  133.             document.getElementById("buddychatroomname").value =  inviteToExistingRoom;
  134. //            document.getElementById("buddychatroomname").setAttribute("value", inviteToExistingRoom);
  135.         }
  136.         else
  137.             chatPreFillRoomName();
  138.  
  139.         document.getElementById("invitedscreennames").focus();
  140.  
  141.  
  142.  
  143.         
  144.         
  145.     }
  146.  
  147. }
  148.  
  149.  
  150. function chatInviteBuddyOnWinUnLoad(){
  151.     //window.close();
  152. }
  153.  
  154. function chatInviteBuddyCmdInvite(){
  155.     dump("chatInviteBuddyCmdIncite\n");
  156.         document.getElementById("cibdeck001").setAttribute("index",3)
  157.  
  158.     //document.getElementById("cibdeck").setAttribute("id",1);
  159.     if(!inviteToExistingWindow){
  160. //        var invitedScreenNames = document.getElementById("invitedscreennames").getAttribute("value");
  161.         var invitedScreenNames = document.getElementById("invitedscreennames").value;
  162. //        var chatRoomName = document.getElementById("buddychatroomname").getAttribute("value");
  163.         var chatRoomName = document.getElementById("buddychatroomname").value;
  164.         dump("setting ChatRoomName "+chatRoomName+"\n")
  165. //        var chatMsg = document.getElementById("invitationmsg").getAttribute("value");
  166.         var chatMsg = document.getElementById("invitationmsg").value;
  167.         dump("screenNames "+invitedScreenNames+"\n");
  168.         
  169.         // just send one argument to window.openDialog - but build an object. This way you dont have to worry about
  170.         // keeping track of the argument's order.
  171.         chatContentArgs = new Object();
  172.         chatContentArgs.invitedScreenNames = invitedScreenNames;
  173.         chatContentArgs.chatRoomName = chatRoomName;
  174.         chatContentArgs.chatMsg = chatMsg;
  175.         // not incoming chat
  176.         chatContentArgs.incomingChat = false;
  177.         chatContentArgs.incomingChatInviteProposalScreenName = ''
  178.         chatContentArgs.incomingChatInviteProposalObj=null
  179.         chatContentArgs.incomingChatRoom=null;
  180.         dump("about to openDialog chatContent.xul\n");
  181.         window.openDialog("chrome://aim/content/chatContent.xul","","chrome,all,dialog=no",chatContentArgs);
  182.  
  183.         
  184.         //window.close();
  185.  
  186.     }
  187.     else{
  188.         dump("myOpener:"+window.opener+"\n")
  189. //        window.opener.chatContentInviteMany(document.getElementById("invitedscreennames").getAttribute("value"),document.getElementById("invitationmsg").getAttribute("value"))
  190.         window.opener.chatContentInviteMany(document.getElementById("invitedscreennames").value,document.getElementById("invitationmsg").value);
  191. //        window.opener.chatMsg = document.getElementById("invitationmsg").getAttribute("value")
  192.         window.opener.chatMsg = document.getElementById("invitationmsg").value;
  193.         window.close();
  194.     }
  195.  
  196. }
  197.  
  198. function cmdChatIncomingWarn()
  199. {
  200.     var warnUserArgs = new Object();
  201.     warnUserArgs.screenName = incomingChatScreenName;
  202.     
  203.     window.openDialog("chrome://aim/content/WarnUser.xul","_blank", "chrome,dialog=no",warnUserArgs)
  204. }
  205.  
  206. function cmdChatIncomingBlock()
  207. {
  208.     var answer = top.confirm( aimString("confirm.BlockUser").replace(/%ScreenName%/, incomingChatScreenName) );
  209.     if ( answer == false )
  210.         return;
  211.         aimPrivacy().DenyListAdd( incomingChatscreenName );
  212.     aimPrivacy().PrivacyMode = aimPrivacyModes().DenyList;
  213. }
  214.  
  215. function cmdChatIncomingIM()
  216. {
  217.     aimIMInvokeIMForm(incomingChatScreenName, null);
  218. }
  219.  
  220. function cmdChatIncomingInfo()
  221. {
  222.  
  223. }
  224.  
  225. function chatInviteBuddyCmdDeclineRendezvous()
  226. {
  227.     inviteProposalObj.Reject();
  228.     window.close();
  229. }
  230.  
  231. function chatInviteBuddyCmdAcceptRendezvous(){
  232.         document.getElementById("cibdeck001").setAttribute("index",3)
  233.  
  234.  
  235.     // code to accept rendezvous here
  236.     var invitedScreenNames = "";
  237.     var chatRoomName=incomingChatRoomName
  238.     var chatMsg = "";
  239.  
  240.  
  241.         // just send one argument to window.openDialog - but build an object. This way you dont have to worry about
  242.         // keeping track of the argument's order.
  243.         chatContentArgs = new Object();
  244.         chatContentArgs.invitedScreenNames = invitedScreenNames;
  245.         chatContentArgs.chatRoomName = chatRoomName;
  246.         chatContentArgs.chatMsg = chatMsg;
  247.         dump('chatInviteBuddy.js :try to accept the proposal \n');
  248.         //inviteProposalObj.Accept();
  249.         // yes incoming chat
  250.         chatContentArgs.incomingChat = true;
  251.         chatContentArgs.incomingChatInviteProposalScreenName = inviteProposalScreenName;
  252.         chatContentArgs.incomingChatInviteProposalObj=inviteProposalObj
  253.         chatContentArgs.incomingChatRoom=incomingChatRoom;
  254.         window.openDialog("chrome://aim/content/chatContent.xul","","chrome,all,dialog=no",chatContentArgs);
  255.     
  256.  
  257. }
  258.  
  259.  
  260. function chatPreFillRoomName(){
  261.     if(pIIMManager){
  262.         // depends on AimSession.js
  263.         var currentScreenName = aimSessionCurrentScreenName()
  264.         //does this need to be instead 001 , 002, 003 ?
  265.         var someRandomNumber = Math.ceil(Math.random()*100);
  266. //        document.getElementById("buddychatroomname").setAttribute("value",currentScreenName+" chat "+someRandomNumber);
  267.         document.getElementById("buddychatroomname").value=currentScreenName+" chat "+someRandomNumber;
  268.  
  269.     }
  270.  
  271. }
  272.